#ifndef BOARD_H
#define BOARD_H

#include <QList>
#include <QGraphicsScene>

#include "boarditem.h"

class Hole;
class Ball;

class Board : public QGraphicsScene
{
    Q_OBJECT
public:
    explicit Board(qint32 size, QObject *parent = 0);

    void drag_ball(Ball *ball);
    void drop_ball(Ball *ball);

public slots:
    void reset();

signals:
    void finish();
    void eaten();

private:
    const qint32 m_size;
    QList<Hole *> m_holes;
    QList<Ball *> m_balls;
    QGraphicsScene m_scene;

    QList<BoardItem::pos_t> game_positions() const;
    QList<BoardItem::pos_t> valid_moves(BoardItem::pos_t const &src) const;
    bool busy(BoardItem::pos_t const &src) const;
    bool accept_move(BoardItem::pos_t const &src, BoardItem::pos_t const &dst);
    BoardItem::pos_t nearest_pos(QPointF const &p) const;
    void highlight_holes(BoardItem::pos_t const &pos, bool enable) const;

    bool no_moves() const;
};

#endif // BOARD_H
